﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sinacor.Servico.Bovespa.Corretagem.Service.ServiceImplementation.Translator.DataContractToBusinessEntity
{
    //Task  : 5617 
    // Data : 13/03/2009
    // Autor:Apsilva
    /// <summary>
    /// Classe Translator de Data Contract para Bussinesss Entiy
    /// </summary>
    public class Desconto
    {
        public BusinessEntity.Desconto ToDesconto(DataContract.Request.DescontoRequest request)
        {
            BusinessEntity.Desconto to = new BusinessEntity.Desconto();
            to.PercentualAllIn = request.PercentualAllIn;
            to.PercentualDescontoAcresimo = request.PercentualDescontoAcresimo;
            BusinessEntity.Periodo periodo = new Sinacor.Servico.Bovespa.Corretagem.BusinessEntity.Periodo();
            if (request.Periodo != null)
            {

                periodo.DataFinal = request.Periodo.DataFinal;
                periodo.DataInicial = request.Periodo.DataInicial;
            }
            to.Periodo = periodo; 
            return to; 
        }

        public List<BusinessEntity.Desconto> ToDesconto(List<DataContract.Request.DescontoRequest>  request)
        {
            List<BusinessEntity.Desconto> to = new List<BusinessEntity.Desconto>();
            foreach (DataContract.Request.DescontoRequest item in request)
            {
                to.Add(ToDesconto(item)); 
            }
            return to;
        }

        public BusinessEntity.Parameter.FiltroDesconto ToFiltroDesconto(DataContract.Request.FiltroDescontoRequest request)
        {
            BusinessEntity.Parameter.FiltroDesconto from = new BusinessEntity.Parameter.FiltroDesconto();
            from.Data = request.Data; 
            return from; 

        }

        public List<BusinessEntity.Parameter.FiltroDesconto> ToFiltroDesconto(List<DataContract.Request.FiltroDescontoRequest> request)
        {
            List<BusinessEntity.Parameter.FiltroDesconto> to = new List<BusinessEntity.Parameter.FiltroDesconto>();
            foreach (DataContract.Request.FiltroDescontoRequest item in request)
            {
                to.Add(ToFiltroDesconto(item)); 
            }
            return to;

        }

        public BusinessEntity.Parameter.FiltroDescontoChave ToFiltroDescontoChave(DataContract.Request.FiltroDescontoChaveRequest request)
        {
            BusinessEntity.Parameter.FiltroDescontoChave to = new Sinacor.Servico.Bovespa.Corretagem.BusinessEntity.Parameter.FiltroDescontoChave();
            to.Data = request.Data;
            to.PercentualAllIn = request.PercentualAllIn;
            to.PercentualDescontoAcresimo = request.PercentualDescontoAcresimo;
            BusinessEntity.Periodo periodo = new Sinacor.Servico.Bovespa.Corretagem.BusinessEntity.Periodo();
            if (request.Periodo != null)
            {
                periodo.DataFinal = request.Periodo.DataFinal;
                periodo.DataInicial = request.Periodo.DataInicial;
            }
            to.Periodo = periodo; 
            return to;
        }
        
        public List<BusinessEntity.Parameter.FiltroDescontoChave> ToFiltroDescontoChave(List<DataContract.Request.FiltroDescontoChaveRequest> request)
        {
            List<BusinessEntity.Parameter.FiltroDescontoChave> to = new List<BusinessEntity.Parameter.FiltroDescontoChave>();
            foreach (DataContract.Request.FiltroDescontoChaveRequest item in request)
            {
                to.Add(ToFiltroDescontoChave(item)); 
            }        

            return to;
        }

    }
}
